package com.xuanxuan.socketdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.xuanxuan.socketdemo.activity.BluetoothClientActivity;
import com.xuanxuan.socketdemo.activity.BluetoothServerActivity;
import com.xuanxuan.socketdemo.activity.ClientActivity;
import com.xuanxuan.socketdemo.activity.ServerActivity;
import com.xuanxuan.socketdemo.activity.TestActivity;
import com.xuanxuan.socketdemo.activity.UdpTestActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn_server = findViewById(R.id.btn_server);
        Button btn_client = findViewById(R.id.btn_client);
        Button btn_test = findViewById(R.id.btn_test);
        Button btn_udp_test = findViewById(R.id.btn_udp_test);
        Button btn_bluetooth_client = findViewById(R.id.btn_bluetooth_client_1);
        Button btn_bluetooth_server = findViewById(R.id.btn_bluetooth_server_1);

        btn_server.setOnClickListener(this);
        btn_client.setOnClickListener(this);
        btn_test.setOnClickListener(this);
        btn_udp_test.setOnClickListener(this);
        btn_bluetooth_client.setOnClickListener(this);
        btn_bluetooth_server.setOnClickListener(this);
    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_server:
                startActivity(new Intent(MainActivity.this, ServerActivity.class));
                break;
            case R.id.btn_client:
                startActivity(new Intent(MainActivity.this, ClientActivity.class));
                break;
            case R.id.btn_test:
                startActivity(new Intent(MainActivity.this, TestActivity.class));
                break;
            case R.id.btn_udp_test:
                startActivity(new Intent(MainActivity.this, UdpTestActivity.class));
                break;
            case R.id.btn_bluetooth_client_1:
                startActivity(new Intent(MainActivity.this, BluetoothClientActivity.class));
                break;
            case R.id.btn_bluetooth_server_1:
                startActivity(new Intent(MainActivity.this, BluetoothServerActivity.class));
                break;
        }
    }
}